import 'package:flutter/material.dart';
import '../pages/cart.dart';
import '../pages/cateroty.dart';
import '../pages/home.dart';
import '../pages/indexpage.dart';
import '../pages/member.dart';
import '../home/home_list.dart';
import '../home/home_swiper.dart';
import '../goods/goods_detal.dart';
import '../home/home_detail.dart';
import '../search/search.dart';
import '../goods/goods_list.dart';
import '../goods/goods_commodity.dart';
import '../map/map.dart';
import '../map/address.dart';
import '../map/addresslist.dart';
import '../login/login.dart';
import '../login/register.dart';
import '../order/order.dart';
import '../video/video.dart';
import '../order/orderdetail.dart';
import '../image/image.dart';
final routes = {
  "/": (context) => IndexPage(),
  '/cate':(context)=>CatePage(),
  '/home':(context)=>HomePage(),
  '/member':(context)=>MemberPage(),
  '/cart':(context)=>CartPage(),
  //'/cart': (context, {arguments}) => CartPage(arguments: arguments),
  '/homelist':(context,{arguments})=>HomeList(arguments: arguments),
  'homeswiper':(context)=>HomeSwiper(),
  '/goodsdetail':(context,{arguments})=>GoodsDetal(arguments:arguments),
  '/homedetail':(context,{arguments})=>HomeDetail(arguments:arguments),
  '/search':(context)=>SearchPage(),
  '/goodslist':(context,{arguments})=>GoodsList(arguments:arguments),
  '/goodscommodity':(context,{arguments})=>GoodsCommodity(arguments:arguments),
  '/map':(context,{arguments})=>Map(arguments:arguments),
   '/address':(context)=>Address(),
    '/addresslist':(context)=>Addreslist(),
     '/login':(context)=>Loginpage(),
      '/register':(context)=>RegisterPage(),
      '/order':(context,{arguments})=>OrderPage(arguments:arguments),
       '/video':(context)=>VideoPage(),
       '/orderdetail':(context,{arguments})=>OrderDetail(arguments:arguments),
       '/image':(context)=>ImagePickerPage()
};
var onGenerateRoute = (RouteSettings settings) {
  print(settings.name);
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  // If you push the PassArguments route
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
      // Cast the arguments to the correct type: ScreenArguments.
      //  final ScreenArguments args = settings.arguments;

      // Then, extract the required data from the arguments and
      // pass the data to the correct screen.
      // return MaterialPageRoute(
      //   builder: (context) {
      //     return PassArgumentsScreen(
      //       title: args.title,
      //       message: args.message,
      //     );
      //   },
      // );
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
